home *** CD-ROM | disk | FTP | other *** search
- /*
- ** $Filename: DLManager.thor
- **
- ** $VER: DLManager v1.5 ©1996-1998
- **
- ** Copyright 1996-1998, Troy E. Bouchard.
- **
- ** Author: Troy E. Bouchard
- ** E-Mail: tbouchar@ptialaska.net
- **
- ** Library Files needed:
- ** bbsread.library (of course)
- ** rexxarplib.library (get it from Aminet!)
- ** rexxsupport.library (get it from Aminet!)
- **
- */
-
- SIGNAL ON SYNTAX
- SIGNAL ON HALT
-
- EVE_ENTERMSG = 0
-
- /* Find our Thor Port and number! */
- p = Address() || ' ' || show('P',,)
- ThorPort = pos('THOR.',p)
-
- if ThorPort > 0 then ThorPort = word(substr(p,ThorPort),1)
- else
- do
- say "Can't seem to find the Thor port!"
- exit 10
- End
-
- /* Load the BBSRead library up! */
- if ~show('p', 'BBSREAD') then
- do
- address command
- "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
- "WaitForPort BBSREAD"
- End
-
- if ~Show('L','rexxarplib.library') then
- do
- if ~AddLib('rexxarplib.library',0,-30,0) then
- do
- Address(ThorPort)
- 'REQUESTNOTIFY TEXT '"Couldn't open rexxarplib.library"' BT "_Exiting!"'
- exit 5
- end
- end
-
- if ~Show('L','rexxsupport.library') then
- do
- if ~AddLib('rexxsupport.library',0,-30,0) then
- do
- Address(ThorPort)
- 'REQUESTNOTIFY TEXT '"Couldn't open rexxsupport.library"' BT "_Exiting!"'
- exit 5
- end
- end
-
- options results
-
- MyPort = OpenPort(DLPORT)
- if MyPort = 0 then
- do
- Address(ThorPort)
- 'REQUESTNOTIFY TEXT '"Couldn't open the port"' BT "_Exiting!"'
- exit 5
- end
-
- address AREXX ,
- "'Call CreateHost(DLHOST,DLPORT)'"
-
- do i = 1 to 10
- if ~Showlist('P',DLHOST) then call delay 50
- else leave i
- end
-
- if i = 10 & ~Showlist('P',DLHOST) then
- do
- Address(ThorPort)
- 'REQUESTNOTIFY TEXT '"Couldn't open the Host"' BT "_Exiting!"'
- exit 5
- end
-
- Call CreateWIN()
-
- WaitStuff:
- fini = 0
-
- do forever
- if fini = 1 then leave
- t = waitpkt(DLPORT)
- do i = 1
- p = getpkt(DLPORT)
- if c2d(p) = 0 then leave i
- cmd = getarg(p)
- j = reply(p,0)
- Select
- When cmd = CLOSEWINDOW then do
- Call Quit()
- end
- When cmd = GETSYSTEM then do
- Call GetSystem()
- win.txt = 'Current System: 'TB_SYSTEM
- Call WindowText(DLHOST, win.txt)
- end
- When cmd = NEWLIST then do
- Call NewList()
- end
- When cmd = WRITEMSG then do
- Call WriteMSG()
- end
- When cmd = DELLIST then do
- Call DeleteList
- end
- When cmd = QUIT then do
- Call Quit()
- end
- When cmd = ABOUT then do
- Call About
- end
- When cmd = EDIT then do
- Call Edit
- end
- When cmd = DELETEU then do
- Call LeaveAlone()
- end
- otherwise nop
- end
- end
- end
- Return
-
- CreateWIN:
- voffseta=0
- voffsetb=0
- gad. = ""
- gad.0 = 28
-
- win.idcmp = "+CLOSEWINDOW+GADGETUP"
- win.flags = "+WINDOWCLOSE+WINDOWDEPTH+BACKFILL+ACTIVATE"
- win.title = "DLManager v1.5"
-
- gad.1.x = 30
- gad.1.y = 38+voffseta
- gad.1.name = "GETSYSTEM"
- gad.1.text = " Get System "
- gad.1.reportstring = "%d"
-
- gad.2.x = 30
- gad.2.y = 56+voffseta
- gad.2.name = "NEWLIST"
- gad.2.text = "New/Add List"
- gad.2.reportstring = "%d"
-
- gad.3.x = 156
- gad.3.y = 38+voffseta
- gad.3.name = "WRITEMSG"
- gad.3.text = " Write Mesg "
- gad.3.reportstring = "%d"
-
- gad.4.x = 156
- gad.4.y = 56+voffseta
- gad.4.name = "DELLIST"
- gad.4.text = " Delete List"
- gad.4.reportstring = "%d"
-
- gad.5.x = 30
- gad.5.y = 74+voffseta
- gad.5.name = "QUIT"
- gad.5.text = " Quit "
- gad.5.reportstring = "%d"
-
- gad.6.x = 156
- gad.6.y = 74+voffseta
- gad.6.name = "ABOUT"
- gad.6.text = " About "
- gad.6.reportstring = "%d"
-
- gad.7.x = 30
- gad.7.y = 92+voffseta
- gad.7.name = "EDIT"
- gad.7.text = " Edit "
- gad.7.reportstring = "%d"
-
- gad.8.x = 156
- gad.8.y = 92+voffseta
- gad.8.name = "DELETEU"
- gad.8.text = " Delete User"
- gad.8.reportstring = "%d"
-
- call SetReqColor(DLHOST,BACKGROUND,4) /* Color the Background */
-
- /* Open the window and set the gadgets! */
- call OpenWindow(DLHOST, 0, 0, 285, 112, win.idcmp, win.flags, win.title)
-
- window.text = ' Current System: ~None~'
- Call WindowText(DLHOST, window.text)
-
- CNT = 0
-
- do n = 1 to gad.CNT
- if gad.n.length = "" then
- call Addgadget(DLHOST, gad.n.x, gad.n.y, ,
- gad.n.name, gad.n.text, gad.n.reportstring)
- else
- call Addgadget(DLHOST, gad.n.x, gad.n.y, ,
- gad.n.name, gad.n.text, gad.n.reportstring, ,
- gad.n.length)
- end
-
- /* Color the Gadgets and activate em! (set activate -> ON
- Call SetGadget(DLHOST, GETSYSTEM, ON)
- Call SetGadget(DLHOST, NEWLIST, ON)
- Call SetGadget(DLHOST, WRITEMSG, ON)
- Call SetGadget(DLHOST, DELLIST, ON)
- Call SetGadget(DLHOST, QUIT, ON)
- Call SetGadget(DLHOST, ABOUT, ON)
- Call SetGadget(DLHOST, EDIT, ON) */
- Return
-
-
- AddTDL:
- Call GetSystemPath()
-
- Address(ThorPort)
- 'RequestFile Title "Select the .tdl file" ID "'DataPath'".tdl FP PAT "#?.tdl"'
- if(rc = 5) then
- do
- 'RequestNotify Text "Request Aborted!" BT "_Wow!"'
- Call WaitStuff
- end
-
- choice = result
-
- if ~Exists(choice) then
- do
- Call Open out, choice, 'w'
- Call Close out
- end
- Return(Choice)
-
- NewList:
- Call AddTDL
- Call AutoManAdd
- Return
-
- WriteCC:
- Address BBSRead
- 'BufMode CopyBack'
- CCAddrStr = ''
- hdr = 'Cc: '
- WAddressStr = hdr||ADDR.i
- i=i+1
- Do j = i to ADDR.COUNT
- Interpret 'NextAddress = ADDR.'j
- if Length(WAddressStr','NextAddress) > 246 then
- do
- CCAddrStr = CCAddrStr||WAddressStr||','||'0a'x
- WAddressStr = ''
- End
- else WAddressStr = WAddressStr','
- WAddressStr = WAddressStr||NextAddress
- End
-
- if WAddressStr > '' then CCAddrStr = CCAddrStr||WAddressStr||'0a'x
-
- TmpFile = 'T:TDL.tmp'
- Call Open out, TmpFile, 'W'
- Call WriteLN out, CCAddrStr
- Call Close out
-
- TmpOpen = Open(out, TmpFile, 'R')
- if (TmpOpen) then do
- TmpLen = Seek(out,0,'E')
- Call Seek(out,0,'B')
- nroflines = 0
- do until (Seek(out,0)=TmpLen)
- HdrLine = ReadLN(out)
- Call Open in, DataPath||EVENT.MSGFILE, 'A'
- Call WriteLN in, HdrLine
- Call Close in
- nroflines = nroflines + 1
- end
- Call Close out
-
- Address Command 'Delete >NIL: 'TmpFile
- 'BufMode EndCopyBack'
- Return
-
- WriteMSG:
- Call GetSig() /* get the pathway to the sig file */
- Call AddTDL() /* get the distribution list */
- Call GetSystemPath() /* get the pathway for the system */
-
- Drop EVENT. /* make sure you free up the event */
- Drop Addr. /* make sure you free up the event */
-
- address(BBSREAD)
- 'UNIQUEMSGFILE bbsname "'TB_SYSTEM'" stem "'TDLFILE'"'
- if(rc ~= 0) then
- do
- Address(ThorPort)
- 'REQUESTNOTIFY TEXT "'BBSREAD.LASTERROR'" BT "_OK"'
- Return
- end
-
- EVENT.CONFERENCE = 'EMail'
- EVENT.MSGFILE = TDLFILE.FILEPART
-
- Call Open out, Choice, 'R'
-
- n = 0
- do while ~eof(out)
- Address = readln(out)
- if Address = '' then leave
- n = n+1
- Interpret 'ADDR.'n' = Address'
- end
-
- ADDR.COUNT = n
- call Close(out)
-
- do i=1 to ADDR.COUNT
- Interpret 'ADDR.'i'= GetListAddr(ADDR.'i')'
- End
-
- Interpret 'EVENT.TONAME = GetListName(Choice)'
-
- AddressStr = ADDR.1
- Do i = 2 to ADDR.COUNT
- Interpret 'NextAddress = ADDR.'i
- if Length(AddressStr','NextAddress) > 246 then
- do
- EVENT.TOADDR = AddressStr
- Call WriteCC ; leave
- End
- else AddressStr = AddressStr','
- AddressStr = AddressStr||NextAddress
- End
-
- EVENT.TOADDR = AddressStr
-
- /* Append the Sig file to the message. */
- SigOpen = Open(out, SigFile, 'R')
- if (SigOpen) then do
- SigLen = Seek(out,0,'E')
- Call Seek(out,0,'B')
- nroflines = 0
- do until (Seek(out,0)=SigLen)
- Sig = ReadLN(out)
- Call Open SigOut, TDLFILE.NAME, 'A'
- Call WriteLN SigOut, Sig
- Call Close SigOut
- nroflines = nroflines + 1
- end
- Call Close out
-
- Address(ThorPort)
- 'REQUESTSTRING TITLE "Please enter your subject:" BT "_Ok|_Cancel" ID "DLManager v1.5" MAXCHARS 100'
- EVENT.SUBJECT = result
- if( rc ~= 0 | EVENT.SUBJECT = '') then
- EVENT.SUBJECT = '(No Subject)' /* You always have to have a subject! */
-
- 'StartEditor 'DataPath||EVENT.MSGFILE /* Start whatever configured editor you are using */
-
- Address BBSREAD
- 'WRITEBREVENT bbsname "'TB_SYSTEM'" event 'EVE_ENTERMSG' stem 'EVENT''
- if(rc ~= 0) then
- do
- Address(ThorPort)
- 'REQUESTNOTIFY TEXT "'BBSREAD.LASTERROR'" BT "_OK"'
- Call Close(fh) /* insanity check! */
- Return
- end
- Return
-
- DeleteList:
- Address(ThorPort)
-
- Call GetSystemPath()
-
- 'RequestFile Title "Select the .tdl file to delete" ID "'DataPath'" FP PAT "#?.tdl"'
- if(rc = 5) then
- do
- 'RequestNotify Text "File Delete Aborted!" BT "_Whew!"'
- Return
- end
-
- Address Command 'Run <>NIL: Delete 'result
- 'RequestNotify Text "File Deleted!" BT "_I Know!"'
- Return
-
- Quit:
- Address(ThorPort)
- 'RequestNotify Text "Do you really\nwant to quit?" BT "_Yes|_No!"'
- if(rc ~= 0) then
- do
- 'RequestNotify Text "'THOR.LASTERROR'" BT "_OK"'
- Call Cleanup
- end
-
- if ( result = 0 ) then Call WaitStuff
- if ( result = 1 ) then Call Cleanup
- Return
-
- SYNTAX:
- SAY 'SYNTAX ERROR'
- SAY 'Error 'rc' in line 'sigl': 'errortext(rc)
- HALT:
- Cleanup:
- Call CloseWindow(DLHOST)
- fini = 1
- Exit
-
- GetListName: procedure
- parse arg name
-
- psn = Lastpos('/', name)
- psn = psn+1
- listname = substr(name, psn)
-
- len = Length(listname)
-
- posn = len-4
- lname = left(listname, posn)
- Return(lname)
-
- GetListAddr: procedure
- parse arg addr
-
- pesn = Lastpos(' ', addr)
- pesn = pesn+1
- listaddr = substr(addr, pesn)
-
- lent = Length(listaddr)
-
- laddr = left(listaddr, lent)
- Return(laddr)
-
- AutoManAdd:
- Address(ThorPort)
- 'RequestNotify Text " Do you want to\n Manually add or\nAdd from User Database?" BT "_Manually|_Add from UDB"'
- if(rc ~= 0) then
- do
- 'RequestNotify Text "'THOR.LASTERROR'" BT "_OK"'
- Call Cleanup
- end
-
- if ( result = 0 ) then call AddUDB
- if ( result = 1 ) then Call AddMan
- return
-
- AddUDB:
- Address BBSREAD
- Call GetSystemPath()
-
- 'SearchBRUser BBSNAME "'TB_SYSTEM'" Stem "'SResult'" Search "#?" Name Address'
- if(rc ~= 0) then
- Do
- Address(ThorPort)
- 'REQUESTNOTIFY TEXT "'BBSREAD.LASTERROR'" BT "_OK"'
- Call Cleanup
- End
-
- if(result > 0) then
- Do
- Address BBSREAD
-
- drop LIST.
- drop USERTAGS.
-
- LIST.COUNT = SResult.COUNT
-
- Do j=1 to SResult.COUNT
- LIST.j.USERNR = SResult.j.USERNR
- 'READBRUSER BBSNAME "'TB_SYSTEM'" UserNR "'SResult.j.USERNR'" TagsStem "'USERTAGS'"'
- if(rc ~= 0) then
- Do
- Address(ThorPort)
- 'RequestNotify Text "'BBSREAD.LASTERROR'" BT "_OK"'
- Return
- End
- LIST.j = USERTAGS.ADDRESS
- End
-
- Address(ThorPort)
- 'REQUESTLIST instem "'LIST'" outstem "'USEL'" Title "Get User:" MultiSelect'
- if(rc ~= 0) then
- Do
- 'RequestNotify Text "Command Cancelled" BT "_OK"'
- Return
- End
- End
-
- if ~Exists(Choice) then
- Call Open out, Choice, 'W'
- Call Close out
-
- Call Open Out, Choice, 'A'
-
- Do k = 1 to USEL.COUNT
- Call WriteLN out, USEL.k
- End
- Call Close out
- Return
-
- AddMan:
- Address(ThorPort)
- Call GetSystemPath()
- 'RequestString TITLE "Enter E-Mail Address:" BT "_OK|_Cancel" ID "tbouchar@ptialaska.net"'
- if(rc ~= 0) then
- do
- 'RequestNotify TEXT "Command Canceled!" BT "_I Know!"'
- return
- end
-
- email = result
-
- if ~Exists(Choice) then
- do
- Call Open out, Choice, 'W'
- Call WriteLN out, email
- Call Close out
- end
- else
- Call Open out, Choice, 'A'
- Call WriteLN out, email
- Call Close out
- Return
-
- About:
- Address(ThorPort)
- 'RequestNotify TEXT "Distribution List Manager v1.5\n by Troy E. Bouchard\n EMail: tbouchar@ptialaska.net" BT "Thanks!"'
- return
-
- Edit:
- Call AddTDL
- Address(ThorPort)
-
- 'StartEditor 'Choice
- return
-
- GetSystemPath:
- Address BBSREAD
- 'GetBBSData "'TB_SYSTEM'" STEM "'GC'"'
- DataPath = GC.BBSPATH
- Return(DataPath)
-
- GetSig:
- Call GetSystemPath()
- Address BBSREAD
- 'GetBBSData "'TB_SYSTEM'" STEM "'BD'"'
- SigFile = BD.SIGNATURE
- Return(SigFile)
-
- GetSystem:
- Address BBSREAD
- 'GETBBSLIST stem "'BBSLIST'"'
- if(rc ~= 0) then
- do
- address(thorport)
- 'REQUESTNOTIFY TEXT "'BBSREAD.LASTERROR'" BT "_Ok"'
- Call Cleanup
- end
-
- Address(ThorPort)
- 'REQUESTLIST instem "'BBSLIST'" title "Select System:" SizeGadget'
- if(rc ~= 0) then
- do
- Call WindowText(DLHOST, "'THOR.LASTERROR'")
- Return
- end
-
- TB_SYSTEM = result
- Return(TB_SYSTEM)
-
- LeaveAlone:
- Call AddTDL()
-
- Drop LIST.
-
- Call Open out, Choice, 'R'
-
- m = 0
- do while ~eof(out)
- ListName = readln(out)
- if ListName = '' then leave
- m = m+1
- Interpret 'LIST.'m' = ListName'
- end
-
- LIST.COUNT = m
- call Close(out)
-
- Drop SELECTED.
- SELECTED.COUNT = 0
-
- Address(ThorPort)
- 'REQUESTLIST Instem LIST Outstem SELECTED Title "Select User(s) to Delete" MultiSelect'
- if rc = 5 then Return
- if rc > 0 then
- Do
- 'RequestNotify Text "'THOR.LASTERROR'" BT "OK"'
- Call Cleanup
- end
-
- TmpFile = 'T:del.tmp'
-
- Call Open out, TmpFile, 'W'
- Call Close out
-
- do j=1 to LIST.COUNT
- if SELECTED.1 ~= LIST.j then
- do
- Call Open out, TmpFile, 'A'
- Call WriteLN out, LIST.j
- Call Close out
- end
- end
-
- Address Command 'Copy >NIL: 'TmpFile Choice
- Address Command 'Delete >NIL: 'TmpFile
- Return
-